<%@page import="model.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	User u = new User();
	if (!u.isAdmin((String) session.getAttribute("lv"))) {
		response.sendRedirect("../index.jsp");
	}
	Film film = new Film();
	National national = new National();
	Categories categories = new Categories();
	Actor actor = new Actor();
	String orby = (String) request.getParameter("sort");
	if (orby != null) {
		if (orby.equals("vn"))
			orby = "film_nvn";
		if (orby.equals("en"))
			orby = "film_nen";
		if (orby.equals("l"))
			orby = "level";
		if (orby.equals("v"))
			orby = "view";
		if (orby.equals("p"))
			orby = "post_on";
		if (orby.equals("u"))
			orby = "uid";
	}
	int[] fid = film.getFID(orby);
%>
<title>MYFILM - Cat Manage</title>
<div>
	<h2>Manage Categories</h2>
</div>
<table>
	<thead>
		<tr>
			<th><a href="film.jsp?sort=vn">Tên VN </a></th>
			<th><a href="film.jsp?sort=en">Tên En</a></th>
			<th><a href="film.jsp?sort=en">Quốc Gia</a></th>
			<th><a href="film.jsp?sort=en">Thể loại</a></th>
			<th><a href="film.jsp?sort=l">Level</a></th>
			<th><a href="film.jsp?sort=v">Lược view</a></th>
			<th><a href="film.jsp?sort=u">Posted by</a></th>
			<th><a href="film.jsp?sort=p">Post On</a></th>
			<th>Dedails</th>
			<th>Edit</th>
			<th>Delete</th>
		</tr>
	</thead>
	<tbody>
	<tr><td><a href="categories.jsp?site=a">Add</a></td><td></td><td></td><td></td><td></td></tr>
		<%
			for (int i:fid) {
				film = film.getFilm(i);
		%>
		<tr>
			<td><%=film.getFilm_nvn()%></td>
			<td><%=film.getFilm_nen()%></td>
			<td><%=national.getNational(film.getNid()).getN_name()%></td>
			<td><%=categories.getCatByID(film.getCid()).getCat_name() %></td>
			<td><%=film.getLevel() %></td>
			<td><%=film.getView() %></td>
			<td><%=u.getUserByID(film.getUid()).getUserName() %></td>
			<td><%=film.getPost_on() %></td>
			<td><a class='edit' href='film.jsp?site=s&fid=<%=i%>'>Dedails</a></td>
			<td><a class='edit' href='film.jsp?site=e&fid=<%=i%>'>Edit</a></td>
			<td><a class='delete' href='delete.jsp?fid=<%=i%>'>Delete</a></td>
		</tr>
		<%
			}
		%>
		
	</tbody>
</table>